package com.baizhi.controller;

import com.baizhi.entity.Student;
import com.baizhi.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;

@Controller
public class StudentController {
    @Autowired
    private StudentService ss;

    @RequestMapping("/insert")
    public String insert(Student st){

        ss.insert(st);

        return "redirect:/showAll.do";
    }

    @RequestMapping("/delete")
    public String delete(int id){

        ss.delete(id);

        return "redirect:/showAll.do";
    }

    @RequestMapping("/update")
    public String update(Student st){

        ss.update(st);

        return "redirect:/showAll.do";
    }

    @RequestMapping("/showAll")
    public String showAll(HashMap map){

         List<Student> list = ss.showAll();
        map.put("map",list);

        return "emplist";
    }

    @RequestMapping("/showOne")
    public String showOne(HashMap map,int id){

        Student list = ss.showOne(id);
        map.put("mapOne",list);

        return "updateEmp";
    }
}
